import VueRouter from 'vue-router'
import Vue from 'vue';

Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
};

const originalreplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(location) {
  return originalreplace.call(this, location).catch(err => err)
};

const routes = [
  {
    path:'',
    redirect:'/home'
   },
  {
   path:'/home',
   component:()=>import('../views/homepage')
  },
  {
    path:'/category',
    component:()=>import('../views/category')
   },
   {
    path:'/buycar',
    component:()=>import('../views/buycar')
   },
   {
    path:'/profile',
    component:()=>import('../views/profile')
   }
]

const router = new VueRouter({
  routes,
  mode:'history',
  linkActiveClass:'active'
})

export default router